package com._21cn.cms.site.service;

import com._21cn.cms.site.dao.SiteDao;
import com._21cn.cms.site.entity.Site;
import com._21cn.framework.base.db.BaseDao;
import com._21cn.framework.base.service.impl.BaseServiceImpl;

import com._21cn.cms.site.dao.ChannelDao;
import com._21cn.cms.site.entity.Channel;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service("channelService")
public class ChannelService extends BaseServiceImpl<Channel> {
	
    @Autowired
    private ChannelDao channelDao;

    @Autowired
    private SiteDao siteDao;

    @Override
    protected BaseDao<Channel> getBaseDao() {
        return channelDao;
    }

    @Override
    public Channel getById( Object id ) {
        Channel channel = super.getById( id );
        if( channel == null ){
            return null;
        }
        int siteId = channel.getSiteId();
        if( siteId>0 ){
            Site site = siteDao.selectById(siteId);
            channel.setSite(site);
        }
        return channel;
    }
}